//呼叫附近AI支援

params["_target", ["_k", 1]];

as_gn_target pushBack [_target, _k];

if(Param_Debug == 1) then{systemChat "ai呼叫支援！"};


//
{
	if(!isNull _x && {count units _x >= 5})then
	{
		private _dis = (leader _x) distance _target;
		if(_dis > Param_EnemyEar && {_dis < Param_SimulationDistance * 1.25})then
		{
			if (Param_Debug == 1) then {systemchat "AI远距离支援";_x setGroupIconParams [[1,0,0,1],"远距离支援",1,true];};
			
			//取消进驻建筑状态
			units _x doFollow leader _x;
			
			//从右侧包围
			//跟踪
			while {(count (waypoints _x)) > 0} do
			{
				deleteWaypoint ((waypoints _x) select 0);
			};
			private _pos_left = (_target) getPos [150 + random 180, ((leader _x) getDir _target) + 90];
			[_x, _pos_left] call fn_addWaypoint;
			_x setBehaviour "AWARE";
			_x setFormation "ECH RIGHT";
			_x setSpeedMode "FULL";
			
			
			if(Param_Debug == 1) then
			{
				private _marker = createMarker [format["marker_wp_%1", as_waypoint_cur], _pos_left];
				_marker setMarkerShape "ICON";
				_marker setMarkerColor "ColorRed";
				_marker setMarkerType "mil_arrow";
				_marker setMarkerText "远距离支援";
				as_waypoint_cur = as_waypoint_cur + 1;
			};
		};
	};
}forEach as_ai_groups;	